<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="schedule/save" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">课程日期</label>
        <div class="layui-input-inline">
        	<select name="week_day" required="required" lay-verify="required">
        		<#if schedule.week_day==1>
        			<option value="1" selected>周一</option>
       			<#else>
        			<option value="1">周一</option>
        		</#if>
        		<#if schedule.week_day==2>
        			<option value="2" selected>周二</option>
       			<#else>
        			<option value="2">周二</option>
        		</#if>
        		<#if schedule.week_day==3>
        			<option value="3" selected>周三</option>
       			<#else>
        			<option value="3">周三</option>
        		</#if>
        		<#if schedule.week_day==4>
        			<option value="4" selected>周四</option>
       			<#else>
        			<option value="4">周四</option>
        		</#if>
        		<#if schedule.week_day==5>
        			<option value="5" selected>周五</option>
       			<#else>
        			<option value="5">周五</option>
        		</#if>
        		<#if schedule.week_day==6>
        			<option value="6" selected>周六</option>
       			<#else>
        			<option value="6">周六</option>
        		</#if>
        		<#if schedule.week_day==7>
        			<option value="7" selected>周日</option>
       			<#else>
        			<option value="7">周日</option>
        		</#if>
        		
		    </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">跳转影片</label>
        <div class="layui-input-inline">
        	<input type='hidden' id="resource_id" value='${schedule.resource_id!""}' name='resource_id'/>
            <input type="text" id="resource_name" name="resource_name" value='${schedule.title!""}' lay-verify="required" required="required" readonly title="请选择影片" placeholder="请选择影片" class="layui-input">
        </div>
        <div class="layui-input-inline">
        	<button data-iframe='resource/select_school_resource' type='button' data-title="选择影片" class='layui-btn layui-btn-small'>选择</button>
        </div> 
    </div>
    <div class="hr-line-dashed"></div>
    <div class="layui-form-item text-center">
        <input type='hidden' value='${schedule.schedule_id!""}' name='id'/>
        <button class="layui-btn" type='button' lay-submit lay-filter="*">保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

    <script>window.form.render();</script>
</form>

<script>
layui.use(['form','upload'], function(){
	var form = layui.form();
	
	//监听提交
    form.on('submit(*)', function (data) {
    	console.log(data.field);
    	$.post('schedule/save', data.field, function (result) { 
			if(result.code==1){
	        	layer.closeAll();
	            layer.msg(result.msg, {
	                icon: 1,
	                shade: this.shade,
	                scrollbar: false,
	                time: 2000,
	                shadeClose: true
	            });//保存成功提示
	            $.form.reload();//刷新表单
	        }else{
	            layer.msg(result.msg, {
	                icon: 2,
	                shade: this.shade,
	                scrollbar: false,
	                time: 3000,
	                shadeClose: true
	            });
	        }
	        
		},"json");
        return false;
    });
	
});

function selectedResource(id,name){
	$('#resource_id').val(id);
	$('#resource_name').val(name);
	layer.close(layer.index);
};
</script>